﻿#pragma once

#include "Part.h"
#include "ProtoBuffer/AllProtocol.h"

class GodPart : public Part
{
	//typedef void (GodPart::*pFunc)(const char*, uint32_t);
	//typedef std::map<uint32_t, pFunc> mapMsgFunc;
	typedef std::map<uint32_t, CharacterGodStruct> mapGodInfo;
private: 
	//mapMsgFunc   m_mapMsgfunc;
	mapGodInfo m_mapGod;   //神格信息
public: 
	GodPart();
	~GodPart();
public:
	virtual bool Init(Creature *pMaster, uint32_t partType, CharacterDBInfo* pCharacterDB = nullptr);
	virtual bool UnInit();
	virtual bool OnMsgHandle(uint32_t cmd, const char* data, uint32_t len);
	virtual void OnExecute(uint16_t nEventID, uint64_t nSrcID, uint8_t bySrcType, void *pContext, int32_t nLen);
	virtual void OnTimer(uint32_t nTimerID);
	virtual bool SynClient(PlayerClientInfo& playerInfo);
	virtual bool SaveDB(CharacterDBInfo& characterDB);
	//增加或减少一个神格的属性 addflag=true为增加，false为减少
	void AddAttr(uint32_t godID, uint32_t level,bool addFlag=true);
	//获取指定神格等级
	uint32_t GetGodLevel(uint32_t godId);
public: //网络消息
	void C2GetGodList(const char* data, uint32_t len);
	void C2GodLevel(const char* data, uint32_t len);
};